<template>
  <div>
    <ul class="mui-table-view">
      <li class="mui-table-view-cell mui-media" v-for="item in newsList" :key="item.id">
        <router-link :to="'/home/newsInfo/'+item.id">
          <img class="mui-media-object mui-pull-left" :src="item.url">
          <div class="mui-media-body">
            <p class="mui-ellipsis-title">{{ item.title }}</p>
            <p class="mui-ellipsis">
              <span>时间：{{ item.addTime | dateFormat('YYYY-MM-DD') }}</span>
              <span>点击：{{ item.click }}次</span>
            </p>
          </div>
        </router-link>
      </li>
    </ul>
  </div>
</template>

<script>
import { Toast } from "mint-ui";
export default {
  data() {
    return {
      newsList: []
    };
  },
  created() {
    this.getNewsList();
  },
  methods: {
    getNewsList() {
      this.$http.get("news#!method=get").then(result => {
        if (result.status === 200) {
          console.log(result);
          this.newsList = result.body.newsList;
        } else {
          Toast("加载新闻失败");
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.mui-ellipsis-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #333;
}
.mui-ellipsis {
  display: flex;
  justify-content: space-between;
}
</style>

